#include "dds_test_tool/dds_test_publisher.h"
#include "dds_test_tool/dds_test_subscriber.h"

#include <gflags/gflags.h>

DEFINE_string(tool_type, "pub", "Publisher or Subscriber");
DEFINE_int32(depth, 5, "History Depth");
DEFINE_bool(reliable, true, "Is Reliable");
DEFINE_double(block_size, 1.0, "Msg Binary Block Size: MB");
DEFINE_double(hz, 10, "Publish Frequency");

int main(int argc , char **argv)
{
    google::AllowCommandLineReparsing();
    google::ParseCommandLineNonHelpFlags(&argc, &argv, false);

    rclcpp::init(argc, argv);

    std::shared_ptr<rclcpp::Node> node = nullptr;

    if(FLAGS_tool_type == "pub"){
        node = std::make_shared<DDSTestPublisher>(FLAGS_depth, FLAGS_reliable ,FLAGS_block_size, FLAGS_hz);
    }else if(FLAGS_tool_type == "sub"){
        node = std::make_shared<DDSTestSubscriber>(FLAGS_depth, FLAGS_reliable);
    }
    
    if(node == nullptr){
        return -1;
    }

    rclcpp::spin(node);
    rclcpp::shutdown();

    return 0;
}